package io.renren.modules.car.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.common.entity.CarTypeEntity;
import io.renren.modules.car.entity.CarEntity;
import io.renren.modules.car.entity.DictRelationEntity;
import io.renren.modules.car.mapper.CarTypeRelationMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 
 * 
 * @author LL
 * @email wdlyl@163.com
 * @date 2022-04-12 14:48:24
 */
@Repository
public class CarTypeRelationDao{
    
    @Autowired
    private CarTypeRelationMapper carTypeRelationMapper;
    
    public List<String> selectDictListByCarId(Integer carId){
        return carTypeRelationMapper.selectDictListByCarId(carId);
    };
    
    public List<Map<String, Object>> batchSelectDictByCardId(List<String> carIds) {
        return carTypeRelationMapper.batchSelectDictByCardId(carIds);
    }
    
    public void deleteDictByCarId(Integer carId) {
        QueryWrapper<DictRelationEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("car_id", carId);
        carTypeRelationMapper.delete(queryWrapper);
    }
    
    public void deleteByCarIds(List<Integer> carIds){
        QueryWrapper<DictRelationEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("car_id", carIds);
        carTypeRelationMapper.delete(queryWrapper);
    }
    
    public void insert(DictRelationEntity dictRelationEntity) {
        carTypeRelationMapper.insert(dictRelationEntity);
    }
}
